<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="edu.tfb.users.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        if(request.getParameter("operacija").equals("Register")){
        String firstName=request.getParameter("firstName");
        String lastName=request.getParameter("lastName");
        String email=request.getParameter("email");
        UserStore.addUser(username,password,firstName,lastName,email);
        }else{
            User logiranKorisnik=UserStore.findUser(username);
            if(logiranKorisnik==null){
            response.sendRedirect("index.jsp?error=Login Failure");
            }
            out.println("<h1>Login successful</h1>");
            }
        %>
        <a href="allUsers.jsp">Prikazi gi site korisnici</a><br/>
        <a href ="index.jsp">Vrati se na glavnata strana za login</a><br/>
         <a href ="register.jsp">Registriranje na nov korisnik</a><br/>
    </body>
</html>